<!--
  @created by huajb on 2020-11-19 11:22:30
  @updated by
  @description 营销任务管理
-->
<div id="marketTaskManager">
	<el-tabs v-model="activeFlag">
		<el-tab-pane label="营销任务下达" name="first" v-if="marketTaskDownTab">
			<yu-panel>
				<el-row :gutter="24">
					<el-col :span="25">
						<yu-xform v-model="marketTask" related-table-name="marketTaskTable" form-type="search">
							<yu-xform-group :column="3">
								<yu-xform-item label="任务名称" label-width="120px" placeholder="任务名称" ctype="input" name="taskName"></yu-xform-item>
								<yu-xform-item label="任务状态" label-width="120px" placeholder="任务状态" ctype="select" name="gridStat" data-code="MARKET_TASK_STAT"></yu-xform-item>
							</yu-xform-group>
						</yu-xform>
						<yu-toolBar>
							<el-button v-if="taskAddButton" @click="taskadd">新增</el-button>
							<el-button v-if="taskEditButton" @click="taskedit">修改</el-button>
							<el-button v-if="taskDeleteButton" @click="taskdelete">删除</el-button>
							<el-button v-if="taskDetailButton" @click="taskdetail">详情</el-button>
							<el-button v-if="taskDownButton" @click="taskgive" type="warning">下达</el-button>
						</yu-toolBar>
						<yu-xtable ref="marketTaskTable" row-number :data-url="marketTaskUrl" selection-type="checkbox" :pageable=true
						 :base-params="marketTaskParams" @cell-dblclick="dbSelected">
							<yu-xtable-column label="营销任务名称" prop="taskName" show-overflow-tooltip width="200" sortable></yu-xtable-column>
							<yu-xtable-column label="指标名称" prop="indexName" width="150" sortable></yu-xtable-column>
							<yu-xtable-column label="营销任务状态" prop="gridStat" width="140" data-code="MARKET_TASK_STAT" sortable></yu-xtable-column>
							<yu-xtable-column label="营销任务开始日期" prop="startDt" width="160" sortable></yu-xtable-column>
							<yu-xtable-column label="营销任务结束日期" prop="endDt" width="160" sortable></yu-xtable-column>
							<yu-xtable-column label="创建时间" prop="createTime" :formatter="dateTimeFormat" width="150"></yu-xtable-column>
							<yu-xtable-column label="创建人" prop="createUserName" width="120" sortable></yu-xtable-column>
							<yu-xtable-column fixed="right" label="操作">
								<template slot-scope="scope">
									<yu-button @click="handleClick(scope.row)" type="text" size="small">指标完成情况</yu-button>
								</template>
							</yu-xtable-column>
						</yu-xtable>
					</el-col>
				</el-row>
			</yu-panel>
			<!--新增/修改-->
			<el-dialog-x :title="title" :visible.sync="addDialogVisible" width="1000px">
				<yu-xform ref="refForm" label-width="140px" v-model="addTaskData">
					<yu-xform-group>
						<yu-xform-item label="任务名称" ctype="input" name="taskName" :disabled="addFormDisabled" rules="required" colspan="12"></yu-xform-item>
						<yu-xform-item label="营销指标" rules="required" ctype="select" name="indexNo" data-code="TARGET_TYPE" @change="selectIndexFn"></yu-xform-item>
						<!-- <yu-xform-item label="执行对象机构" v-if="performType" style="height: 36px" ctype="yufp-org-tree" rules="required" :params="params"colspan="12"  @select-fn="setOrgName" name="execTopyNum"></yu-xform-item>
						<yu-xform-item label="执行对象" v-if="!performType"  style="height: 36px" ctype="yufp-mgr-selector" rules="required" @select-fn-name="setExecName" colspan="12" name="execTopyNum" ></yu-xform-item> -->
						<!-- <yu-xselect label="执行对象" ref="xselect" v-model="value" :options="options" placeholder="请选择" filterable default-first-option collapse-tags multiple></yu-xselect> -->
						<!-- <yu-xform-item label="执行对象" ctype="select" name="gridIds" :disabled="addFormDisabled" rules="required" colspan="12" :data-url="taskGridUrl" :data-params="taskGridParam" multiple></yu-xform-item> -->
						<yu-xform-item label="营销客群" ctype="select" name="custGroupNo" :disabled="addFormDisabled" rules="required"
						 colspan="12" :data-url="taskGroupsUrl" :data-params="taskGroupsParam"></yu-xform-item>
						<yu-xform-item label="任务开始日期" rules="required" ctype="datepicker" value-format="yyyy-MM-dd" align="right"
						 :disabled="addFormDisabled" :editable="false" colspan="12" name="startDt"></yu-xform-item>
						<yu-xform-item label="任务结束日期" rules="required" ctype="datepicker" value-format="yyyy-MM-dd" align="left"
						 :disabled="addFormDisabled" :editable="false" colspan="12" name="endDt"></yu-xform-item>
					</yu-xform-group>
					<div class="yu-grpButton">
						<yu-button v-if="title =='新增营销任务'" @click="saveAddFn">保存</yu-button>
						<yu-button v-if="title =='修改营销任务'" @click="saveAddFn">保存</yu-button>
						<yu-button @click="cancelFn">取消</yu-button>
					</div>
				</yu-xform>
			</el-dialog-x>
			<el-dialog-x title="下发" :visible.sync="transmitDialogVisible" width="600px">
				<!-- <yu-xform ref="refFormTransmit" label-width="120px" v-model="transmitTaskData" > -->
				<!-- <yu-xform-group>
						<yu-xform-item label="执行对象" ctype="select" name="gridIds" rules="required" colspan="16" :data-url="taskGridUrl"
						 :data-params="taskGridParam"  multiple lock-height="140px"></yu-xform-item>
					</yu-xform-group> -->
				<el-select multiple collapse-tags v-model='selectedArray' @change='changeSelect' placeholder='请选择'>
					<el-checkbox v-model="checked" @change='selectAll'>全选</el-checkbox>
					<el-option v-for='(item, index) in levelGrid' :key='index' :label='item.value' :value='item.key'></el-option>
				</el-select>
				<!-- <yu-xselect v-model="value" :data-url="taskGridUrl" :data-params="taskGridParam" placeholder="请选择" filterable></yu-xselect> -->
				<!-- <yu-xselect ref="xselect" v-model="value" :options="levelGrid" placeholder="请选择" filterable default-first-option collapse-tags multiple></yu-xselect> -->
				<div class="yu-grpButton">
					<yu-button @click="transmitFn">保存</yu-button>
					<yu-button @click="cancelFn">取消</yu-button>
				</div>
				<!-- </yu-xform> -->
			</el-dialog-x>
			<el-dialog-x title="营销任务详细" :visible.sync="detailDialogVisible" width="1300px">
				<yu-xform label-width="180px" ref="refFormDetail" v-model="detailData" :disabled="true">
					<yu-xform-group>
						<yu-xform-item label="营销任务编号" ctype="input" name="taskNo" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务名称" ctype="input" name="taskName" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务状态" ctype="select" name="gridStat" data-code="MARKET_TASK_STAT" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销指标" ctype="select" name="indexNo" data-code="TARGET_TYPE" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务开始时间" ctype="datepicker" name="startDt" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务结束时间" ctype="datepicker" name="endDt" :colspan="12"></yu-xform-item>
						<yu-xform-item label="创建时间" ctype="datepicker" name="createTime" :colspan="12"></yu-xform-item>
						<yu-xform-item label="创建人" ctype="input" name="createUserName" :colspan="12"></yu-xform-item>
						<!-- <yu-xform-item label="最近维护人名称" ctype="input" name="lastUpdateUserName" :colspan="12"></yu-xform-item> -->
						<!-- <yu-xform-item label="最近维护时间" ctype="datepicker" name="lastUpdateTime" :colspan="12"></yu-xform-item> -->
					</yu-xform-group>
					<div class="yu-grpButton">
						<yu-button @click="detailDialogVisible=false">取消</yu-button>
					</div>
				</yu-xform>
			</el-dialog-x>
		</el-tab-pane>
		<el-tab-pane label="我的营销任务" name="second" v-if="myMarketTaskTab">
			<yu-panel>
				<el-row :gutter="24">
					<el-col :span="25">
						<yu-xform related-table-name="myMarketTaskTable" ref="myMarketSearchForm" form-type="search" label-width="120px"
						 :custom-search-fn="myMarketSearchFn">
							<yu-xform-group :column="3">
								<yu-xform-item label="任务名称" placeholder="任务名称" ctype="input" name="taskName"></yu-xform-item>
								<yu-xform-item label="任务状态" placeholder="任务状态" ctype="select" name="gridStat" data-code="MARKET_TASK_STAT"></yu-xform-item>
							</yu-xform-group>
						</yu-xform>
						<yu-toolBar>
							<el-button @click="mytaskdetail">详情</el-button>
						</yu-toolBar>
						<yu-xtable ref="mymarketTaskTable" row-number :data-url="mymarketTaskUrl" selection-type="checkbox" :pageable=true
						 :base-params="myMarketTaskParams">
							<yu-xtable-column label="营销任务名称" prop="taskName" width="250" sortable></yu-xtable-column>
							<yu-xtable-column label="网格名称" prop="gridName" width="150" sortable></yu-xtable-column>
							<!-- <yu-xtable-column label="营销任务状态" prop="gridStat" width="150" data-code="MARKET_TASK_STAT"  sortable></yu-xtable-column> -->
							<yu-xtable-column label="营销指标" prop="indexNo" width="150" data-code="TARGET_TYPE" sortable></yu-xtable-column>
							<yu-xtable-column label="营销任务开始时间" prop="startDt" width="180" sortable></yu-xtable-column>
							<yu-xtable-column label="营销任务结束时间" prop="endDt" width="180" sortable></yu-xtable-column>
							<yu-xtable-column label="创建时间" prop="createTime" width="150" sortable></yu-xtable-column>
							<yu-xtable-column label="创建人" prop="createUserName" width="120" sortable></yu-xtable-column>
							<!-- <yu-xtable-column label="最近维护人名称" prop="lastUpdateUserName" width="150" sortable></yu-xtable-column> -->
							<!-- <yu-xtable-column label="最近维护日期" prop="lastUpdateTime" width="150" sortable></yu-xtable-column> -->
							<yu-xtable-column fixed="right" label="操作">
								<template slot-scope="scope">
									<yu-button @click="handleClick(scope.row)" type="text" size="small">指标完成情况</yu-button>
								</template>
							</yu-xtable-column>
						</yu-xtable>
					</el-col>
				</el-row>
			</yu-panel>
			<el-dialog-x title="营销任务详细" :visible.sync="mydetailDialogVisible" width="1300px">
				<yu-xform label-width="180px" ref="myRefFormDetail" v-model="mydetailData" :disabled="true">
					<yu-xform-group>
						<yu-xform-item label="营销任务名称" ctype="input" name="taskName" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务状态" ctype="select" name="gridStat" data-code="MARKET_TASK_STAT" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销指标" ctype="select" name="indexNo" data-code="TARGET_TYPE" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务开始时间" ctype="datepicker" name="startDt" :colspan="12"></yu-xform-item>
						<yu-xform-item label="营销任务结束时间" ctype="datepicker" name="endDt" :colspan="12"></yu-xform-item>
						<yu-xform-item label="创建时间" ctype="datepicker" name="createTime" :colspan="12"></yu-xform-item>
						<yu-xform-item label="创建人" ctype="input" name="createUserName" :colspan="12"></yu-xform-item>
						<!-- <yu-xform-item label="最近维护人名称" ctype="input" name="lastUpdateUserName" :colspan="12"></yu-xform-item> -->
						<!-- <yu-xform-item label="最近维护时间" ctype="datepicker" name="lastUpdateTime" :colspan="12"></yu-xform-item> -->
					</yu-xform-group>
					<div class="yu-grpButton">
						<yu-button @click="detailDialogVisible=false">取消</yu-button>
					</div>
				</yu-xform>
			</el-dialog-x>
		</el-tab-pane>
		<el-dialog-x title="指标完成情况" :visible.sync="targetDialogVisible" width="1300px">
			<yu-xform label-width="180px" ref="targetTable" v-model="targetData" :disabled="true">
				<yu-xtable :data-url="targetTaskUrl" :pageable=true :base-params="targetTaskParams">
					<yu-xtable-column label="营销任务名称" prop="taskName" show-overflow-tooltip width="200" sortable></yu-xtable-column>
					<yu-xtable-column label="指标名称" prop="indexName" width="150" sortable></yu-xtable-column>
					<yu-xtable-column label="营销任务开始日期" prop="startDate" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="营销任务结束日期" prop="endDate" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="名单客户数" prop="namelistCustNum" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="成功营销客户数" prop="successCustNum" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="发布期初值" prop="issuedValue" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="当前值" prop="currentValue" width="160" sortable></yu-xtable-column>
				</yu-xtable>
			</yu-xform>
		</el-dialog-x>
		<el-dialog-x title="指标完成情况" :visible.sync="targetVlueDialogVisible" width="1300px">
			<yu-xform label-width="180px" ref="targetValueTable" v-model="targetValueData" :disabled="true">
				<yu-xtable :data-url="targetValueTaskUrl" :pageable=true :base-params="targetTaskParams">
					<yu-xtable-column label="营销任务名称" prop="taskName" show-overflow-tooltip width="200" sortable></yu-xtable-column>
					<yu-xtable-column label="客户名称" prop="custName" width="150" sortable></yu-xtable-column>
					<yu-xtable-column label="客户身份证号" prop="idNum" width="150" sortable></yu-xtable-column>
					<yu-xtable-column label="指标名称" prop="indexName" width="150" sortable></yu-xtable-column>
					<yu-xtable-column label="营销任务开始日期" prop="startDate" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="营销任务结束日期" prop="endDate" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="是否营销成功" prop="successFlag" data-code="YES_NO" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="发布期初值" prop="issuedValue" width="160" sortable></yu-xtable-column>
					<yu-xtable-column label="当前值" prop="currentValue" width="160" sortable></yu-xtable-column>
				</yu-xtable>
			</yu-xform>
		</el-dialog-x>
	</el-tabs>
</div>
